package util;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.io.Serializable;

/**
 * Created by fenglixiong on 2017/8/20.
 */
public class JsonOut implements Serializable {

    private int ret;
    private String message;
    private String extra;
    private Object object;

    public JsonOut() {

    }

    public JsonOut(int ret) {
        this.ret = ret;
    }

    public JsonOut(int ret, String message) {
        this.ret = ret;
        this.message = message;
    }

    public JsonOut(int ret, String message, String extra) {
        this.ret = ret;
        this.message = message;
        this.extra = extra;
    }

    public JsonOut(int ret, String message, Object obj){
        this.ret = ret;
        this.message = message;
        this.object = obj;
    }

    public int getRet() {
        return ret;
    }

    public void setRet(int ret) {
        this.ret = ret;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getExtra() {
        return extra;
    }

    public void setExtra(String extra) {
        this.extra = extra;
    }

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }


    @JsonIgnore
    public String getJson(){
        Gson gson = new GsonBuilder()
                .setDateFormat("yyyy-MM-dd HH:mm:ss").create();
        return gson.toJson(this);
    }

}
